<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Individual Report</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<link href="./EldercareMasterPage/_finalstyle.css" rel="stylesheet" />
	<link href="./css/bootstrap.min.css" rel="stylesheet" media="screen">
    <link href="./css/bootstrap-datetimepicker.min.css" rel="stylesheet" media="screen">
</head>
<?php
	define('CONFIG_FILE',true);
	include './config.php';
	define('DB_FILE',true);
	
	session_start();
	if (empty($_SESSION["username"])||empty($_SESSION["userType"])) {
		Header("Location: ./Index.php");
		exit();
	}else{
		$userType = $_SESSION["userType"];
	}
	if (!empty($_REQUEST["NRIC"])) {
		$NRIC = $_REQUEST["NRIC"];
	}
	
	// set timeout period in seconds
	$inactive = 7200;
	// check to see if $_SESSION['timeout'] is set
	if (isset($_SESSION["timeout"])) {
		$session_life = time() - $_SESSION["timeout"];
		if ($session_life > $inactive) {
			session_destroy();
			Header("Location: Timeout.php");
		}
	}
	$_SESSION["timeout"] = time();
?>
<body>
    <div class="banner">
	</div>
	<div id="main">
		<div class="left-wrapper">
			<div class="logo">
				<img src="images/eldercare.gif" alt="logo" width="240px" />
			</div>
			<div class="menu-wrapper">
				<div id="cssmenu">        
						<?php
							if ($userType == "Therapy Assistant") {
								include_once('./Sidebar/_SidebarTA.php');
							} else if ($userType == "Centre Manager") {
								include_once('./Sidebar/_SidebarCM.php');
							} else {
								include_once('./Sidebar/_SidebarSA.php');
							}
						?>                     
				</div> 
				<div class="clear"></div></div>
		</div>
		<div id="content">		
			<div class="content2">
				<b style="float:right; margin: 0px 0 0 0">  
					<?php
						if (!empty($_SESSION["centreName"])) {
							$Username = $_SESSION["username"];
							$centreName = $_SESSION["centreName"];
							echo "Welcome, " . $Username . " ! " . $centreName . " Branch";
						} else {
							$Username = $_SESSION["username"];
							echo "Welcome, " . $Username;
						}
					?>
					<input type="submit" class="btn btn-danger" value="Logout" onclick="parent.location = 'logout.php'">
				</b>
				</p>
                <br>
				<div style="float:center">
				<br>		
				<h3>Individual Reports</h3>
				<br> 
				<form name="reportdates" method="POST" class="form-horizontal">
					<div class="control-group">
						<b>Month:</b>
						<div class="controls input-append date form_date" data-link-field="dtp_input1">
							<input  size="16" type="text" value="" readonly>
							<span class="add-on"><i class="icon-remove"></i></span>
							<span class="add-on"><i class="icon-th"></i></span>
						</div>
						<input name="date"  type="hidden" id="dtp_input1" value="" />
						<b> &nbsp; &nbsp; Category: </b> 
						<select name='ddlCategory'>
							<option value="All" selected>All</option>
							<?php				
								echo
								//****************************************//
								//****************************************//
								require_once './Tool/DB/SqlDBManager.class.php';
								$sqlDBManager = new SqlDBManager();
								$sql="Select DISTINCT Category FROM activity";
								$res=$sqlDBManager->queryRows($sql);
								if(!empty($res)){
									for($i=0;$i<count($res);$i++){
										echo "<option value='".$res[$i]['Category']."'>".$res[$i]['Category']."</option>";
									}
								}														
							?>
						</select>
						<?php
							$queryString=$_GET['queryString'];
							echo "<input type=\"hidden\" value=\"".$queryString."\"/>";
						?>	
						&nbsp; &nbsp;<input type="submit" button class="btn"id="submit" value ='Submit'name="submit"/>
						&nbsp; &nbsp;<input type="reset" button class="btn"id="back" value ='Back'name="Back" style="width:80px"onclick="goBack()"/>
					</div>					
				</form>
				</p>
				<p></p>
				<p>
				<?php
					if (isset($_POST['submit'])) {
						if(!empty($_POST['date'])){
							if(!empty($_POST['ddlCategory'])){
								include_once('./IndividualRpts/IndividualRptService.php');
							}else{
								echo "<font color=red>Please select one category.</font>";
							}
						}else{
							echo "<font color=red>Please select one Month.</font>";
						}		
					}
				?>
			</div><div class="clear"></div>
		</div>
	</div>
	</div>
<div id="footer">&copy; 2013 MP22 IIT-IT Temasek Polytechnic</div>
</body> 
<script type="text/javascript" src="./js/jquery-1.8.3.min.js" charset="UTF-8"></script>
<script type="text/javascript" src="./js/bootstrap.min.js"></script>
<script type="text/javascript" src="./js/bootstrap-datetimepicker.js" charset="UTF-8"></script>
<script type="text/javascript">
	$('.form_date').datetimepicker({
		format:"MM",
		autoclose: 1,
		startView: 3,
		minView: 3,
		forceParse: 0,
		pickerPosition:'bottom-left',
    });

    function goBack(){
	    window.location="./IndividualRpts.php";
    }
</script>
</html>

